package xyz.lwm.lazycat.beans;

import lombok.Data;
import xyz.lwm.lazycat.setting.Setting;

import java.util.Map;

/**
 * bean condition for bean design
 *
 * @author lwm
 */
@FunctionalInterface
public interface Condition {

    /**
     * true 则允许注册 design
     *
     * @param ctx condition context
     * @param design bean design
     */
    boolean matches(Context ctx, BeanDesign<?> design);

    /**
     * Condition Context
     */
    @Data
    class Context {

        /**
         * design map, 不包含当前需要判断条件的 design
         */
        private final Map<String, BeanDesign<?>> designMap;

        /**
         * 获取配置信息
         */
        private final Setting setting;

    }

}
